<template>
    <!-- pages/wechatPay/wechatPay.wxml -->
    <view>
        <view class="title">付款方式：</view>
        <view class="pay">
            <view>
                <image src="/static/pages/wechatPay/img/wechat.png"></image>
                微信
            </view>
            <view class="ck"><van-checkbox v-model="checked" @change="onChange" checked-color="#00BCAB"></van-checkbox></view>
        </view>
        <view class="btn" @tap="next">下一步</view>
    </view>
</template>

<script>
// import vanCheckbox from '@vant/weapp/checkbox/index';
// pages/wechatPay/wechatPay.js
import config from './../../utils/config.js';
export default {
    components: {
        // vanCheckbox
    },
    data() {
        return {
            checked: true,
            datas: '',
			from:'01',
			lltParkingInfoType:''
        };
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
		if(options.lltParkingInfoType == 3){
			var param = options.param
		}else{
			var param = JSON.parse(decodeURIComponent(options.param));
		}
        this.setData({
            datas: param,
			from:options.from || "01",
			lltParkingInfoType:options.lltParkingInfoType
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    // onShareAppMessage: function () {
    // }
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */ methods: {
        next() {
            if (this.checked == false) {
                uni.showToast({
                    title: '请选择支付方式',
                    icon: 'none'
                });
                return;
            }
			// if(this.lltParkingInfoType == 3){
			// 	jWeixin.miniProgram.navigateTo({url:"/pages/wxContent/wxContent?param=" + this.datas + "&from=" + this.from })
			// }else{
				var miniPayRequest = this.datas.miniPayRequest ? JSON.parse(this.datas.miniPayRequest) : this.datas; //调用支付
				if (uni.getStorageSync('weixin') == 2){
					if(miniPayRequest.package){
						var packages = miniPayRequest.package.split('_id=')[1]
					}else{
						uni.showToast({
							title:'参数错误，请重新尝试'
						})
						return
					}
				}
				jWeixin.miniProgram.navigateTo({url:"/pages/wxPay/wxPay?nonceStr=" + miniPayRequest.nonceStr + '&package=' + packages  + '&paySign=' + encodeURI(miniPayRequest.paySign) + '&timeStamp=' + miniPayRequest.timeStamp + "&from=" + this.from })
			// }
        },

        onChange(event) {
            this.setData({
                checked: event.detail
            });
        },

        getRandom() {
            var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
            var maxPos = $chars.length;
            var pwd = '';

            for (let i = 0; i < 32; i++) {
                pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
            }

            console.log(pwd);
            return pwd;
        }
    }
};
</script>
<style>
@import './wechatPay.css';
</style>
